package gold.digger;

import gold.utils.InputUtil;
import gold.vo.CodeDoc;

/**
 * Created by fanzhenyu02 on 2020/6/27.
 * common problem solver template.
 */
public class LC283 {
    public long startExecuteTime = System.currentTimeMillis();

    //    Input: [0,1,0,3,12]
//    Output: [1,3,12,0,0]
    public void moveZeroes(int[] arr) {
        if (null == arr || arr.length <= 0) return;

        int pre = 0, cur = 0;
        for (; cur < arr.length; cur++) {
            if (arr[cur] == 0) continue;
            arr[pre++] = arr[cur];
        }

        for (int i = pre; i < arr.length; i++) {
            arr[i] = 0;
        }
    }


    public static void main(String[] args) throws Exception {
        LC283 an = new LC283();
        int[] arr = InputUtil.toIntegerArray("[0,1,0,3,12]");
        an.moveZeroes(arr);
        InputUtil.run();
        CodeDoc.run();
        System.out.println("\nanswer total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
